# -*- coding=utf-8
# appid 已在配置中移除,请在参数 Bucket 中带上 appid。Bucket 由 BucketName-APPID 组成
# 1. 设置用户配置, 包括 secretId，secretKey 以及 Region
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
import sys
import logging


def create_bucket():
    logging.basicConfig(level=logging.INFO, stream=sys.stdout)

    secret_id = 'AKID1RcbIjINMAi37ux2RZR2VhcOs87svGtD'  # 替换为用户的 secretId
    secret_key = 'C7UabQv9AuPdIq8CzVsa1DH4dxzkMhlh'  # 替换为用户的 secretKey
    region = 'ap-nanjing'  # 替换为用户的 Region
    bucket = 'luchaohuai-1302866811'
    config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key)
    # 2. 获取客户端对象
    client = CosS3Client(config)
    # 高级上传图片
    # client.delete_object(
    #     Bucket='luchaohuai-1302866811',
    #     Key='123.jpg',
    # )
    objects = {
        "Quiet": "true",
        "Object": [
            {
                "Key": "p1.jpg"
            },
            {
                "Key": "456.jpg"
            }
        ]
    }

    # 批量删除图片
    client.delete_objects(
        Bucket='luchaohuai-1302866811',
        Delete=objects
    )


create_bucket()
